package com.shenmazong.clone;

/**
 * @program: server-java-demo
 * @description: HeroApplication
 * @author: 亮子说编程
 * @create: 2020-10-16 09:00
 **/
public class HeroCopyApplication {
    public static void main(String[] args) {
        //-- 新建对象
        HeroSkill skill = new HeroSkill("打虎");
        Hero hero = new Hero("武松", 19, skill);
        System.out.println(hero);

        System.out.println("========= 开始复制 ===========");

        //-- 拷贝对象
        Hero hero1 = new Hero();
        hero1.setHeroName(hero.getHeroName());
        hero1.setHeroAge(hero.getHeroAge());
        hero1.setHeroSkill(hero.getHeroSkill());
        System.out.println(hero);
        System.out.println(hero1);

        System.out.println("========= 开始修改 ===========");

        //-- 修改对象
        hero1.setHeroName("鲁智深");
        hero1.getHeroSkill().setSkillName("拔树");
        System.out.println(hero);
        System.out.println(hero1);
    }
}
